public class Test {
    public static int[] abc(){
        int[] a = new int[]{5,4,3,2,1};
        return a;
    }

    public static void main(String[] args) {
        int[] array = abc();
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i]+" ");
        }
    }
    public static void change(int[] a){
        a[0] = 10;
    }
    public static void main7(String[] args) {
        int[] array = new int[]{1,2,3,4,5};
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i]+" ");
        }
        System.out.println();
        change(array);
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i]+" ");
        }
    }
    public static void main4(String[] args) {
        int[] array = new int[]{1,2,3,4,5,6,7,8,9,0};
        //在JAVA中可以通过 数组名.length 来获得数组的长度
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
        System.out.println();
        //叫做 加强for循环，前一个参数是数组元素的类型，后一个参数是数组名
        for (int x: array) {
            System.out.print( x + " ");
        }
    }
    public static void main3(String[] args) {

        /**
         * 动态初始化
         */
        int[] array1 = new int[10];
        /**
         * 静态初始化
         */
        int[] array2 = new int[]{1,2,3,4,5,6};
        //看似省略了new int[]，实际上编译器编译时会自动加上
        int[] array3 = {1,2,3,4,5,6};
        //可以分为两步写
        int[] array4;
        array4 = new int[10];

        int[] array5;
        array5 = new int[]{1,2,3,4,5};
        /**
         * 错误写法
         * int[] array4 = new int[3]{1,2,3};
         * int[] array5 = new int[];
         * 不能这样初始化
         * int array = new int[10];
         * array = {1,2,3,4,5,6,7,8,9,0};
         */
    }






    //sum构成重载
    public static int sum(int a, int b){
        return a + b;
    }
    //参数的类型不同
    public static double sum(double a, double b){
        return a + b;
    }
    //参数的数量不同
    public static int sum(int a, int b, int c){
        return a + b + c;
    }

    //mul构成重载
    //参数的顺序不同
    public static double mul(double a, float b){
        return 1.0;
    }
    public static double mul(float a, double b){
        return 2.0;
    }
    public static void main2(String[] args) {

    }

    public static void main1(String[] args) {
        int ret = sum(1,2);
        System.out.println("较大值为：" + ret);
        /*switch(1.0){
            case 1.0:
                System.out.println("1");
                break;
            case 2.0:
                System.out.println("2");
                break;
            default:
                break;
        }*/
        /*while(1){
            System.out.println("123");
        }*/
    }
}